package com.winit;

import com.winit.commons.util.ObjectToString;
import com.winit.employeInfo.model.Dept;
import com.winit.employeInfo.model.Duty;
import com.winit.employeInfo.model.Employee;
import com.winit.employeeDataExtract.EmployeeDataExtractor;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Application.class)
public class DataInit {

    @Test
    public void Test1() throws Exception {
        //研发中心部门列表
        List<String> yfdept = new ArrayList<>();
        List<String> devdept = new ArrayList<>();
        List<String> qadept = new ArrayList<>();
        List<String> opsdept = new ArrayList<>();
        List<String> pdmdept = new ArrayList<>();
        //研发中心职位列表
//        List<String> yfduty = new ArrayList<>();
//        List<String> devduty = new ArrayList<>();
//        List<String> qaduty = new ArrayList<>();
//        List<String> opsduty = new ArrayList<>();
//        List<String> pdmduty = new ArrayList<>();

        //部门
        List<Dept> depts = EmployeeDataExtractor.extractDept();
        for (Dept dept : depts) {
            if ("Y".equals(dept.getIsdisable())) {
                continue;
            }
            //研发中心部门
            if ("YF01".equals(dept.getDeptcode()) || "YF01".equals(dept.getSupername()) || yfdept.contains(dept.getSupername())) {
                yfdept.add(dept.getDeptcode());
                if (dept.getDeptname().contains("技术产品管理部") || pdmdept.contains(dept.getSupername())
                        || dept.getDeptname().contains("产品")) {
//                    System.out.println("pdm============="+dept.getDeptname());
                    pdmdept.add(dept.getDeptcode());
                } else if (dept.getDeptname().contains("质量保证部") || qadept.contains(dept.getSupername())
                        || dept.getDeptname().contains("测试")) {
//                    System.out.println("qa============="+dept.getDeptname());
                    qadept.add(dept.getDeptcode());
                } else if (dept.getDeptname().contains("运维支持部") || opsdept.contains(dept.getSupername())) {
//                    System.out.println("ops============="+dept.getDeptname());
                    opsdept.add(dept.getDeptcode());
                } else {
//                    System.out.println("dev============="+dept.getDeptname());
                    devdept.add(dept.getDeptcode());
                }
            }
        }

        //职位
//        List<Duty> dutys = EmployeeDataExtractor.extractDuty();
//        for (Duty duty : dutys) {
//            if (!yfdept.contains(duty.getDeptname())) {
//                continue;
//            }
//            yfduty.add(duty.getDutycode());
//            if (pdmdept.contains(duty.getDeptname())) {
//                pdmduty.add(duty.getDutycode());
//            } else if (qadept.contains(duty.getDeptname())) {
//                qaduty.add(duty.getDutycode());
//            } else if (devdept.contains(duty.getDeptname())) {
//                devduty.add(duty.getDutycode());
//            } else if (opsdept.contains(duty.getDeptname())) {
//                opsduty.add(duty.getDutycode());
//            } else {
//                System.out.println(ObjectToString.getString(duty));
//            }

//            if (duty.getDutyname().contains("产品")) {
//                pdmduty.add(duty.getDutycode());
//            } else if (duty.getDutyname().contains("测试")|| duty.getDutyname().contains("质量保证部")) {
//                qaduty.add(duty.getDutycode());
//            } else if (duty.getDutyname().contains("开发") || duty.getDutyname().contains("java")
//                    || duty.getDutyname().contains("JAVA") || duty.getDutyname().contains("PHP")
//                    || duty.getDutyname().contains("JS") || duty.getDutyname().contains("前端")
//                    || duty.getDutyname().contains("Java") || duty.getDutyname().contains("UI")
//                    || duty.getDutyname().contains("UE") || duty.getDutyname().contains("研发")
//                    || duty.getDutyname().contains("项目经理") || duty.getDutyname().contains("Android")
//                    || duty.getDutyname().contains("系统工程部")) {
//                devduty.add(duty.getDutycode());
//            } else if (duty.getDutyname().contains("运维") || duty.getDutyname().contains("网络")
//                    || duty.getDutyname().contains("DBA") || duty.getDutyname().contains("BDA")
//                    || duty.getDutyname().contains("数据库")) {
//                opsduty.add(duty.getDutycode());
//            } else {
//                System.out.println(ObjectToString.getString(duty));
//            }
//        }

        //人员
        List<Employee> employees = EmployeeDataExtractor.extractEmployee();
        for (Employee employee : employees) {
            if(!"1".equals(employee.getHirestate()) || StringUtils.isEmpty(employee.getEmail())){
                continue;
            }
            if(devdept.contains(employee.getDeptcode())){
                System.out.println("dev============="+employee.getEmpname());
            }else if(qadept.contains(employee.getDeptcode())){
                System.out.println("qa============="+employee.getEmpname());
            }else if(opsdept.contains(employee.getDeptcode())){
                System.out.println("ops============="+employee.getEmpname());
            }else if(pdmdept.contains(employee.getDeptcode())){
                System.out.println("pdm============="+employee.getEmpname());
            }else {
                System.out.println("pd============="+employee.getEmpname());
            }
        }
    }

}
